package com.shootingGame
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.Event;

	public class EffectsManager extends MovieClip
	{
		public function EffectsManager()
		{
			super();
		}
		
		override public function addChild(child:DisplayObject):DisplayObject{
			super.addChild(child);
			child.addEventListener(Event.ENTER_FRAME, checkForAnimationEnded);
			//MovieClip(child).gotoAndPlay(1);
			return child;
			
		}
		
		private function checkForAnimationEnded(evt : Event) : void {
			var effect : MovieClip = MovieClip(evt.currentTarget);
			if(effect.currentFrame == effect.totalFrames){
				effect.removeEventListener(Event.ENTER_FRAME, checkForAnimationEnded);
				//if(contains(effect))
					removeChild(effect);
			}
		}
		
		
		
	}
}